package net.simflow.swf.analyzer.t2flow.opt;

import java.io.File;

import net.simflow.swf.analyzer.t2flow.data.T2FlowDocument;

import uk.org.taverna.scufl2.api.container.WorkflowBundle;
import uk.org.taverna.scufl2.api.io.WorkflowBundleIO;

public class T2FlowFileParser {

	private static T2FlowFileParser instance = new T2FlowFileParser();

	private T2FlowFileParser() {
	}

	public static T2FlowFileParser getInstance() {
		return instance;
	}

	public T2FlowDocument parse(File t2flow) {
		if (t2flow == null) {
			return null;
		}
		WorkflowBundle wb = null;
		try {
			wb = (new WorkflowBundleIO()).readBundle(t2flow,
					"application/vnd.taverna.t2flow+xml");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new T2FlowDocument(t2flow, wb);
	}
}
